import React from "react";
import { Avatar } from "antd-mobile";
import { useSelector } from "react-redux";
import styles from "./css/me.module.css";
import { useNavigate } from "react-router-dom";

function Userinfo() {
  let nav = useNavigate();
  let info = useSelector((store) => store.user.info);
  return (
    <div>
      {info ? (
        <div className={styles.avatar}>
          <Avatar src={info.avatar}></Avatar>
          <div className={styles.tel}>{info.username || info.tel}</div>
        </div>
      ) : (
        <div onClick={() => nav("/login")}>
          <Avatar src="/"></Avatar>
          <div>登录/注册</div>
        </div>
      )}
    </div>
  );
}

export default Userinfo;
